package com.yaowk.web.mall.clothing.controller;

import com.yaowk.api.common.PageReq;
import com.yaowk.api.common.PageResp;
import com.yaowk.api.mall.clothing.model.MemberLevel;
import com.yaowk.api.mall.clothing.service.IMemberLevelService;
import com.yaowk.api.mall.clothing.web.MemberLevelModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by yaowk on 17-10-20.
 */
@RestController
@RequestMapping("/mall/clothing/memberLevel")
@Api(tags = "会员等级")
public class MemberLevelController {

    @Autowired
    private IMemberLevelService memberLevelService;

    @GetMapping
    @ApiOperation("查询会员等级列表")
    public PageResp<MemberLevelModel> list(PageReq pageReq) {
        PageResp<MemberLevelModel> result = memberLevelService.findAllOfWeb(pageReq);
        return result;
    }

    @PostMapping
    @ApiOperation("保存会员等级")
    public MemberLevel save(MemberLevel memberLevel) {
        memberLevel = memberLevelService.save(memberLevel);
        return memberLevel;
    }

    @ApiOperation("删除会员等级")
    @DeleteMapping("/{id}")
    public void delete(@PathVariable Integer id) {
        memberLevelService.deleteById(id);
    }

    @ApiOperation("查看会员等级详情")
    @GetMapping("/{id}")
    public MemberLevel memberLevel(@PathVariable Integer id) {
        MemberLevel memberLevel = memberLevelService.findById(id);
        return memberLevel;
    }
}
